$(function () {
    $("#jqGrid").jqGrid({
        url: baseURL + '/merchant/requirementlist',
        datatype: "json",
        colModel: [         
        { label: 'ID', name: 'id', width: 30, key: true },
        { label: '商品名称', name: 'name', width: 100 },
        {label:"平台",name:"platform",width: 40},
        {label:"发布者",name:"publisher",width: 60},
        {label:"审核类型",name:"type",width: 50,formatter: function(value, options, row){
            if(value==0){  return  "手动审核";}
            else if (value==1) {return "自动审核";}

        }},
        {label:"商品单价",name:"price",width: 50,formatter: function(value, options, row){
            return  value+"元";

        }},
        {label:"佣金",name:"brokerage",width: 30,formatter: function(value, options, row){
            return  value+"元";

        }},
        { label: '发布数量', name: 'num', width: 50 },
        {label:"保证金",name:"bail",width: 40,formatter: function(value, options, row){
            return  value+"元";

        }},
        { label: '当前状态', name: 'status', width: 100,formatter: function(value, options, row){
                if(value==1){
                    return "待管理员审核";
                }
                else if(value==2){
                    return "正在发布中";
                }
                else if(value==3){
                    return "试用已满额";
                }
                else if(value==4){
                    return "已结束";
                }
            } },
        { label: '发布时间', name: 'createTime', width: 100,formatter: function(value, options, row){
            return  parseTime(value);
        }}
        ],
        viewrecords: true,
        height: 555,
        rowNum: 10,
        rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "data.dataList",
            page: "data.currentPage",
            total: "data.total",
            records: "page.totalNum"
        },
        prmNames : {
            page:"pageNo", 
            rows:"pageSize", 
            order: "order"
        },
        gridComplete:function(){
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });
});
var vm = new Vue({
    el:'#rrapp',
    data:{
        q:{
            key: null
        },
        showList: true,
        title: null
    },
    methods: {
        reload: function () {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam','page');
            $("#jqGrid").jqGrid('setGridParam',{ 
                postData:{'key': vm.q.key},
                page:page
            }).trigger("reloadGrid");
        }
    }
});